"use strict";
cc._RF.push(module, '5539bKgqDxHA4O0Wsdk7oAB', 'LoginViewUI');
// scripts/LoginViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
},
    ss = void 0 && (void 0).__generator || function (t, e) {
  var o,
      i,
      n,
      a,
      r = {
    label: 0,
    sent: function sent() {
      if (1 & n[0]) throw n[1];
      return n[1];
    },
    trys: [],
    ops: []
  };
  return a = {
    next: s(0),
    "throw": s(1),
    "return": s(2)
  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
    return this;
  }), a;

  function s(t) {
    return function (e) {
      return l([t, e]);
    };
  }

  function l(a) {
    if (o) throw new TypeError("Generator is already executing.");

    for (; r;) {
      try {
        if (o = 1, i && (n = 2 & a[0] ? i["return"] : a[0] ? i["throw"] || ((n = i["return"]) && n.call(i), 0) : i.next) && !(n = n.call(i, a[1])).done) return n;

        switch (i = 0, n && (a = [2 & a[0], n.value]), a[0]) {
          case 0:
          case 1:
            n = a;
            break;

          case 4:
            return r.label++, {
              value: a[1],
              done: !1
            };

          case 5:
            r.label++, i = a[1], a = [0];
            continue;

          case 7:
            a = r.ops.pop(), r.trys.pop();
            continue;

          default:
            if (!(n = (n = r.trys).length > 0 && n[n.length - 1]) && (6 === a[0] || 2 === a[0])) {
              r = 0;
              continue;
            }

            if (3 === a[0] && (!n || a[1] > n[0] && a[1] < n[3])) {
              r.label = a[1];
              break;
            }

            if (6 === a[0] && r.label < n[1]) {
              r.label = n[1], n = a;
              break;
            }

            if (n && r.label < n[2]) {
              r.label = n[2], r.ops.push(a);
              break;
            }

            n[2] && r.ops.pop(), r.trys.pop();
            continue;
        }

        a = e.call(t, r);
      } catch (s) {
        a = [6, s], i = 0;
      } finally {
        o = n = 0;
      }
    }

    if (5 & a[0]) throw a[1];
    return {
      value: a[0] ? a[1] : void 0,
      done: !0
    };
  }
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("GlobalParams"),
    n = e("HardData"),
    i = e("HardKey"),
    r = e("AssetsManager"),
    s = e("nameCfg"),
    l = e("CommonHelper"),
    _ = e("sdkConfig"),
    c = e("Game"),
    d = e("Loader"),
    h = e("RoleSoldierInfo"),
    u = cc._decorator,
    p = u.ccclass,
    m = u.property,
    f = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.loading_bar = null, t.loading_label = null, t.tip_label = null, t.logo_node = null, t.advice_node = null, t.preBundleList = ["fight", "roles_prefabs"], t.necessaryBundleList = ["Images", "Atlas", "Hall", "animation", "Role"], t.bundleLoadState = {}, t;
  }

  return nn(t, e), t.prototype.onLoad = function () {
    cc.director.getCollisionManager().enabled = !0, cc.director.getPhysicsManager().enabled = !0, cc.game.setFrameRate(60);
  }, t.prototype.start = function () {
    _["default"].platform = _.EPlatform.VIVO;
    this.advice_node.active = _["default"].platform != _.EPlatform.TikTok, a.GlobalParams.gameSound = new n["default"](a.GlobalParams.game_name + i.DataKey.Sound, !0), a.GlobalParams.gameMusic = new n["default"](a.GlobalParams.game_name + i.DataKey.Music, !0), a.GlobalParams.gameShock = new n["default"](a.GlobalParams.game_name + i.DataKey.Short, !0), a.GlobalParams.addDeskIcon = new n["default"](a.GlobalParams.game_name + i.DataKey.addDeskTopIsOn, !1), a.GlobalParams.showPrivacy = new n["default"](a.GlobalParams.game_name + i.DataKey.show_privacy, !1), a.GlobalParams.ShareVidoeInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.share_video, 0), a.GlobalParams.JoinGuideMode = new n["default"](a.GlobalParams.game_name + i.DataKey.guide_mode, !0), a.GlobalParams.ChooseIconInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.choose_icon, 0), a.GlobalParams.NewHeroInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.new_hero, {
      open_today: 0,
      hero_id: 16
    });
    var e = a.GlobalParams.NewHeroInfo.value;
    e.hero_id != a.GlobalParams.NewHeroId && (e.hero_id = a.GlobalParams.NewHeroId, a.GlobalParams.NewHeroInfo.value = e), a.GlobalParams.PlayerInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.PlayerInfo, {
      coin: 200,
      zs: 0,
      debris: 0,
      name: "",
      level: 1,
      max_level: 1,
      exp: 0,
      head: 1,
      have_head: [],
      change_mode: 0,
      revive: 5,
      unlock_skill: [1, 2],
      free_coin: 0,
      tast_card: 0,
      first_fight: !0,
      house_box: 0
    });
    var t = a.GlobalParams.PlayerInfo.value;

    if ("" == t.name && (_["default"].platform == _.EPlatform.NET_4399 ? (t.name = "4399玩家" + l["default"].getRandomInt(1e3, 5e3), t.have_head = [1]) : (t.name = s["default"].nameList[l["default"].getRandomInt(0, 10)], t.have_head = [1, 2], t.head = l["default"].getRandomInt(1, 2)), a.GlobalParams.PlayerInfo.value = t), a.GlobalParams.PlayerSigninInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.signin_info, {
      signin_num: 0,
      signin_date: 0
    }), a.GlobalParams.playerSkinInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.player_skin_info, {
      use: [1],
      have_hero: [1]
    }), a.GlobalParams.FightDataInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.fight_data, {
      win_num: 0,
      fight_num: 0,
      data_info: [0, 0, 0, 0, 0]
    }), a.GlobalParams.LuckyBoxInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.lucky_box_info, {
      last_award: !0,
      gift_num: 0,
      open_today: 0,
      get_day: 0
    }), a.GlobalParams.ShopDowerInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.shop_dower_info, {
      info: [],
      now_date: 0,
      free: !0
    }), a.GlobalParams.PlayerDowerInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.player_dower_info, {
      dower: [1, 1, 1, 1, 1]
    }), a.GlobalParams.PlayerTaskInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.player_task_info, {
      schedule: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      today: 0
    }), a.GlobalParams.PlayerTaskInfo.value.today != new Date().toLocaleDateString()) {
      var o = a.GlobalParams.PlayerTaskInfo.value;
      o.schedule = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], o.today = new Date().toLocaleDateString(), a.GlobalParams.PlayerTaskInfo.value = o;
    }

    a.GlobalParams.PlayerSeasonInfo = new n["default"](a.GlobalParams.game_name + i.DataKey.player_season_info, {
      free_award: [],
      extra_award: [],
      today_exp: 0
    }), a.GlobalParams.DungeonModeHero = new n["default"](a.GlobalParams.game_name + i.DataKey.dungeon_info, {
      update_dare: !1,
      hero: [-1, -1, -1],
      power: 0,
      dare_times: 5,
      today: 0,
      dare_info: [],
      power_info: []
    }), a.GlobalParams.GameHeroIndex = [];

    for (var r = [], c = 1; c < h["default"].Role_info.length; c++) {
      -1 == r.indexOf(c) && a.GlobalParams.GameHeroIndex.push(c);
    }

    -1 != [_.EPlatform.TikTok, _.EPlatform.NET_4399].indexOf(_["default"].platform) && (a.GlobalParams.showPrivacy.value = !0), a.GlobalParams.start_time = new Date().getTime(), a.GlobalParams.showMaxDis = Math.sqrt(Math.pow(cc.winSize.width, 2) + Math.pow(cc.winSize.height, 2)) + 100, this.showTipInfo(), this.loadBundle();
    var d = cc.tween(this.logo_node).to(1.5, {
      scale: 1.2
    }).to(1.5, {
      scale: 1
    }).call(function () {
      d.start();
    }).start();
  }, t.prototype.loadBundle = function () {
    for (var e = this, t = function t(_t) {
      d["default"].loadSubpackage(o.necessaryBundleList[_t], function () {
        e.loadOneSubpackage(e.necessaryBundleList[_t]);
      }, !0);
    }, o = this, a = 0; a < this.necessaryBundleList.length; ++a) {
      t(a);
    }

    a = 0;

    for (var n = this.preBundleList.length; a < n; ++a) {
      d["default"].loadBundle(this.preBundleList[a], null, !1, !1);
    }
  }, t.prototype.loadOneSubpackage = function (e) {
    this.bundleLoadState[e] = !0;

    for (var t = 0, o = 0; o < this.necessaryBundleList.length; o++) {
      this.bundleLoadState[this.necessaryBundleList[o]] && t++;
    }

    console.log(this.necessaryBundleList, t);
    t == this.necessaryBundleList.length && this.changeScene();
  }, t.prototype.changeScene = function () {
    return rr(this, void 0, void 0, function () {
      var e = this;
      return ss(this, function (t) {
        console.log(t, t.label);

        switch (t.label) {
          case 0:
            return this.setProgress(), this.setLabel("加载游戏图集。。。"), [4, r["default"].getInstance().loadFolder("Atlas", r.AssetsType.Atlas)];

          case 1:
            return t.sent(), this.setProgessOver(), this.setLabel("加载游戏预支资源。。。"), [4, r["default"].getInstance().loadFolder("Hall", r.AssetsType.Bundle)];

          case 2:
            return t.sent(), this.setProgessOver(), this.setLabel("加载音效资源。。。"), [4, r["default"].getInstance().loadFolder("sound/main_sound", r.AssetsType.Audio)];

          case 3:
            return t.sent(), this.setProgessOver(), this.setLabel("加载主场景资源。。。"), cc.director.preloadScene("Main", null, function (t) {
              t ? console.error("======场景加载错误========", t) : (e.unscheduleAllCallbacks(), cc.tween(e.loading_bar).to(0.2, {
                width: 1250
              }).call(function () {
                if (a.GlobalParams.showPrivacy.value) cc.director.loadScene("Main");else {
                  var t = r["default"].getInstance().getPrefabNode("tip_view_ui");
                  e.node.parent.addChild(cc.instantiate(t));
                }
              }).start());
            }), [2];
        }
      });
    });
  }, t.prototype.setLabel = function (e) {
    this.loading_label.string = e;
  }, t.prototype.setProgress = function () {
    var e = this;
    this.loading_bar.width = 0;
    var t = cc.tween(this.loading_bar).by(0.2, {
      width: 10
    }).call(function () {
      e.loading_bar.width < 1250 && t.start();
    });
    t.start();
  }, t.prototype.setProgessOver = function () {
    var e = this;
    this.loading_bar.stopAllActions(), cc.tween(this.loading_bar).to(0.2, {
      width: 1250
    }).call(function () {
      e.setProgress();
    }).start();
  }, t.prototype.showTipInfo = function () {
    var e = this;
    this.tip_label.string = c["default"].login_tip_list[l["default"].getRandomInt(0, c["default"].login_tip_list.length - 1)], cc.tween(this.tip_label).delay(3).call(function () {
      e.showTipInfo();
    }).start();
  }, oo([m(cc.Node)], t.prototype, "loading_bar", void 0), oo([m(cc.Label)], t.prototype, "loading_label", void 0), oo([m(cc.Label)], t.prototype, "tip_label", void 0), oo([m(cc.Node)], t.prototype, "logo_node", void 0), oo([m(cc.Node)], t.prototype, "advice_node", void 0), oo([p], t);
}(cc.Component);

o["default"] = f;

cc._RF.pop();